home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 693 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c,comp.std.c,finet.atk.kielet.c
  4. Subject: Re: TYPEDEF and Watcom C++ 10.5
  5. Date: Wed, 03 Apr 96 16:49:42 GMT
  6. Organization: none
  7. Distribution: world
  8. Message-ID: <828550182snz@genesis.demon.co.uk>
  9. References: <4jlu1r$cs7@nic.dataphone.se>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <4jlu1r$cs7@nic.dataphone.se>
  16.            skorpio@dataphone.se "Jarmo Paavilainen" writes:
  17.  
  18. >
  19. >typedef struct
  20. >{
  21. >WORD    CheckSum;
  22. >WORD    Version;
  23. >BYTE    PatchLevel;
  24. >BYTE    Name[21];
  25. >WORD    MarkerVersion;
  26. >}VERSION_TAG_STRUCT;
  27. >
  28. >Shouldn't sizeof(VERSION_TAG_STRUCT) always result in 28. By other words
  29. >shouldn't WORD always be 16 bits and BYTE 8 bits.
  30.  
  31. BYTE and WORD aren't defined by the C language so it is up to your
  32. implementation or whatever code defined them to select a suitable C type
  33. for them.
  34.  
  35. Also be aware that compilers can add padding anywhere in a structure (except
  36. before the first member), usually to ensure that the members are aligned
  37. appropriately.
  38.  
  39. >If so why does my compiler claim that sizeof(VERSION_TAG_STRUCT) == 34.
  40. >All this in 32 bit OS/2 PM and Watcom C++ 10.5
  41.  
  42. Why don't you check what sizeof(WORD) is on your system by writing a program
  43. to print it out (sizeof(BYTE) can't be more than 1 with the size of the
  44. whole structure being 34).
  45.  
  46. -- 
  47. -----------------------------------------
  48. Lawrence Kirby | fred@genesis.demon.co.uk
  49. Wilts, England | 70734.126@compuserve.com
  50. -----------------------------------------
  51.